// 国信证券：518800309526
const { WebSocketServer } = require("ws")
const wss = new WebSocketServer({ port: 3000 })

class GuoXin {
    static holdingList = []
    constructor() {
        this.ws = null
        wss.on("connection", (ws) => {
            this.ws = ws
            ws.on("message", (e) => {
                try {
                    let { fn, data } = JSON.parse(e)
                    this[fn]({ data })
                }
                catch (err) { }
            })
        })
    }
    setHoldingList({ data }) {
        if (!data || !Array.isArray(data.result)) return false
        GuoXin.holdingList = data.result
        console.log(data.result.map((item) => item.stkcode))
    }
    getHoldingList() {
        return GuoXin.holdingList
    }
}

module.exports = GuoXin